<?php

class Webmix_Form_Webmix_Create extends Engine_Form
{
    
  public function init()
  {
    $view = Zend_Registry::get('Zend_View');
    $this
      ->setTitle('Create new webmix');
      

    $this->addElement('text','webmix_name',array(
        'label' => $view->translate('Webmix name'),
        'required' => true,
        'allowEmpty' => false
    ));
    $viwer = Engine_Api::_()->user()->getViewer();
    /*if($viewer->isAdmin()){
        $countryTable = Engine_Api::_()->getDbtable('countries','webmix');
        $rows = $countryTable->fetchAll($countryTable->select()->where('selected = 1'));
        $countries = array();
        $countries[0] = 0;
        foreach($rows as $item){
            $countries[$item->country_id] = $item->title;
        }
        $this->addElement('select','country_id',array(
            'label' => $view->translate('Select country'),
            'multiOptions' => $countries
        ));
    }*/
    
    $viewer = Engine_Api::_()->user()->getViewer();
    $webmixTable = Engine_Api::_()->getDbtable('webmixes','webmix');
    $select = $webmixTable->select()
                          ->where('content_type = 1')
                          ->where('owner_id = ?',$viewer->user_id);
    $row = $webmixTable->fetchRow($select);
    if(!$row){
        $this->addElement('select','content_type',array(
            'label' => $view->translate('Select Type'),
            'multiOptions' => array(
                '0' => 'Internet',
                '1' => 'Music'
            )
        ));
        
    }  
    
    
    
    $this->addElement('Button', 'submit', array(
      'type' => 'submit',
      'label' => 'Create',
      'decorators' => array('ViewHelper')
    ));

    $this->addElement('Cancel', 'cancel', array(
      'label' => 'cancel',
      'link' => true,
      'prependText' => Zend_Registry::get('Zend_Translate')->_(' or '),
      'href' => '',
      'onclick' => 'parent.Smoothbox.close();',
      'decorators' => array(
        'ViewHelper'
      )
    ));
    $this->addDisplayGroup(array('submit', 'cancel'), 'buttons');
    $button_group = $this->getDisplayGroup('buttons');

  }
}